﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="msg_recent_msgview.aspx.cs" Inherits="Ccit.SysPlat.Remind.msg_recent_msgview" %>

<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>协作交流-联系详情</title>
</head>
<body onload="doInitPage()">
    <ccit:ActionForm id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        </asp:ScriptManager>
        <!--当前联系人-->
        <input type="hidden" id="_hidRecentId" runat="server" />
        <!--总页数-->
        <input type="hidden" id="_hidSumPage" runat="server" />
        <!--总记录数-->
        <input type="hidden" id="_hidSumData" runat="server" />
        <!--当前页的数据-->
        <input type="hidden" id="_hidCurMsgData" runat="server" />
        
        <table cellpadding="0" cellspacing="0" class="tbToolbar" width="98%" align="center">
            <tr>
              <td align="left">
                <div class="tbSeparator"></div>
              </td>
              <td width="95%" class="titlebar">协作交流-联系详情</td>
              <td align="right">
                <div class="tbSeparator"></div>
              </td>
            </tr>
          </table>
          
         
         <table id="tabQuery" cellpadding="0" runat="server" cellspacing="0" align="center" width="98%"  height="5px" style="margin-top:3px">
         <tr>
           <td>
              <fieldset style="width:100%">
                 <table cellpadding="0" cellspacing="0" width="100%" align="center" height="3px" >
                  <tr>
                     <td style="width:80%" align="right">
                       <nobr>
                        发送时间 <input type="text" runat="server" id="txtBeginTime"  class="input"  style="width:100px" readonly/>
                        <IMG class="getdate" id="IMG1" title="选择日期" src="../images/toolbar/Calendar.gif" relaobj="txtBeginTime">
                       </nobr>
                    </td>
                    <td style="width:13%" align="right">
                      <nobr>
                         到 <input type="text" runat="server" id="txtEndTime"  class="input"   style="width:100px" readonly/>
                        <IMG class="getdate" id="IMG2" title="选择日期" src="../images/toolbar/Calendar.gif" relaobj="txtEndTime">
                      </nobr>  
                    </td>
                    <td style="width:7%" align="right">
                       <nobr>
                          <a href="javascript:doInitPage()" title="查询" class="linktext">
                             <img src="../images/toolbar/search.gif" />
                          </a>
                      </nobr>
                    </td>
                  </tr>
                </table>
              </fieldset>
           </td>
         </tr>
        </table>
        
        <table id="tabViewMsg"  runat="server" class="tableborder"  cellpadding="0" runat="server" cellspacing="0" align="center" width="98%" style="margin-top:3px">
            <tr id="trNoData" runat="server">
                <td colspan="4" height="80px" class="tbcommentBottom" align="center" width="100%" valign="middle"><font size="2px">No data to display</font></td>
            </tr>   
        </table>
        
        <table id="tabPage" border="0" cellspacing="0" cellpadding="0" align="center" runat="server" style="width:98%">
            <tr>
              <td class="pformright" bgcolor="#FFFFFF" style="text-align:right;">
                  <a id="haFirst" href="javascript:doGetPageData('first')" class="linktext">【第一页】</a>
                  <a id="haBefore" href="javascript:doGetPageData('before')" class="linktext">【上一页】</a>
                  <a  id="haNext" href="javascript:doGetPageData('next')" class="linktext">【下一页】</a>
                  <a  id="haLast" href="javascript:doGetPageData('last')" class="linktext">【最后一页】</a>
                   【第&nbsp;<font color=#ff0000><asp:Label ID="lblCurPageNo" runat="server" Text="0"></asp:Label></font>&nbsp;页】
                   【每页&nbsp;<font color=#ff0000>15</font>&nbsp;条记录】
                   【共&nbsp;<font color=#ff0000><asp:Label ID="lblRowCount" runat="server" Text="0"></asp:Label></font>&nbsp;条记录】
                   【共&nbsp;<font color=#ff0000><asp:Label ID="lblPageCount" runat="server" Text="0"></asp:Label></font>&nbsp;页】&nbsp;</td>
              </tr>
             <tr class="pformstrip" width="98%">
             <td colspan="2" align="center">
                   <input type="button" runat="server" id="btnClose"  class="button" value="关闭" onclick="doClose()"/>
             </td>
           </tr>
        </table>
    </ccit:ActionForm>
    
    <script type="text/javascript" language="javascript">
    
        var vTab;
        var vCurCount = 15;  //每页15条数据
        function doInitPage()
        {
            var oPageNo=parseInt(document.getElementById("lblCurPageNo").innerHTML,"10");
            var vRecentId = document.getElementById("_hidRecentId").value;
            var beginTime = document.getElementById("txtBeginTime").value;
            var endTime = document.getElementById("txtEndTime").value;
            
            var check = true;
            
            if(beginTime != "" && endTime != "")
            {
                check = compareDate(beginTime,endTime);
            }
            if(check)
               PageMethods.GetRecentMsgInfo(vRecentId,oPageNo,vCurCount,beginTime,endTime,ClientCallBack);
            else
               alert("起始日期不能大于终止日期");
        }
        
        /* 判断起始日期大小 */
        function compareDate(DateOne,DateTwo)   
        {
            var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ("-"));   
            var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ("-")+1);   
            var OneYear = DateOne.substring(0,DateOne.indexOf ("-"));   
              
            var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ("-"));   
            var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ("-")+1);   
            var TwoYear = DateTwo.substring(0,DateTwo.indexOf ("-"));   
              
            if (Date.parse(OneMonth+"/"+OneDay+"/"+OneYear) <=   
            Date.parse(TwoMonth+"/"+TwoDay+"/"+TwoYear))   
            {   
                return true;   
            }   
            else  
            {   
                return false;   
            } 
        }  

        
        
        function ClientCallBack(vResult)
        {
            eval("var vResultObj=" + vResult);
            document.getElementById("lblPageCount").innerHTML = vResultObj.oSumPage;
            document.getElementById("lblRowCount").innerHTML = vResultObj.oSumData;
            document.getElementById("_hidCurMsgData").value = vResultObj.oCurData;
            
            SetJumpStyle(); //设置分页样式
            
            doFillData();  //填充数据
        }
          
        function doFillData()
        {
            var vCurData = document.getElementById("_hidCurMsgData").value;  //当前数据
            if(vCurData != "")
            {
                eval("var lstRecent=" + vCurData);
                vTab = document.getElementById("tabViewMsg");  
                var vTableCount=vTab.rows.length;
                if(lstRecent.length>0)
                    document.getElementById("trNoData").style.display="none";
                    
                var oRowCount=vTab.rows.length;
                for(var i=1;i<oRowCount;i++)
                     vTab.deleteRow(1);
                    
                for(var i =0; i < lstRecent.length; i ++)
                {
                    var RecentMsg = lstRecent[i];
                    doCreateMsgRow(RecentMsg,i);
                }
            }
            else
            {
                document.getElementById("haFirst").style.disabled=true;
                document.getElementById("haBefore").style.disabled=true;
                document.getElementById("haNext").style.disabled=true;
                document.getElementById("haLast").style.disabled=true;
            }
        }
        //创建行
        function doCreateMsgRow(vRecentMsg,iLine)
        {
            var vRow = vTab.insertRow();
            vRow.id = "row_" + vRecentMsg.MsgId;
            
            vRow.width = "100%";
            
            var vctrl;
            var oParam="recentId="+vRecentMsg.ReceiverId+"&MsgId="+vRecentMsg.MsgId+"&MsgFrom="+vRecentMsg.MsgType;
            var oEncodeParam=base64encode(oParam);
            var oUrl="msg_attach_view.aspx?"+oEncodeParam;
            var ocell=vRow.insertCell();
            ocell.width="100%";
            octrl=document.createElement("<iframe id='frmComment_"+vRecentMsg.MsgId+"' height='99%' width='100%' frameborder='0'  src='"+oUrl+"'>");
            ocell.appendChild(octrl);    
        }    
        
        function doGetPageData(vType)
        {
            var vCurPageNo = parseInt(document.getElementById("lblCurPageNo").innerHTML,"10");
            switch(vType)
            {
                case "first":
                     vCurPageNo = 1;
                     break;
                case "before":
                     vCurPageNo--;
                     break;
                case "next":
                     vCurPageNo++;
                     break;
                case "last":
                     vCurPageNo = document.getElementById("lblPageCount").innerHTML;
                     break;
            }
            document.getElementById("lblCurPageNo").innerHTML=vCurPageNo;
            doInitPage();
        }   
        
          /* 设置页面跳转链接样式 */
        function SetJumpStyle()
        {
            var oCurrPageNo = parseInt(document.getElementById("lblCurPageNo").innerHTML,"10");
            var vSumPage = parseInt(document.getElementById("lblPageCount").innerHTML,"10");
        
            var vhaFirst = document.getElementById("haFirst");
            var vhaBefore = document.getElementById("haBefore");
            var vhaNext = document.getElementById("haNext");
            var vhaLast = document.getElementById("haLast");
            
            if(vSumPage>1)
            {
                if(oCurrPageNo==1)
                {
                    vhaFirst.disabled=true;
                    vhaFirst.removeAttribute("href");
                    vhaBefore.disabled=true;
                    vhaBefore.removeAttribute("href");
                    
                    vhaNext.disabled=false;
                    vhaNext.href="javascript:doGetPageData('next')";
                    vhaLast.disabled=false;
                    vhaLast.href="javascript:doGetPageData('last')";
                }
                else if(oCurrPageNo==vSumPage)
                {
                    vhaNext.disabled=true;
                    vhaNext.removeAttribute("href");
                    vhaLast.disabled=true;
                    vhaLast.removeAttribute("href");
                    
                    vhaFirst.disabled=false;
                    vhaFirst.href="javascript:doGetPageData('first')";
                    vhaBefore.disabled=false;
                    vhaBefore.href="javascript:doGetPageData('before')";
                }
                else
                {
                   vhaFirst.disabled=false;
                   vhaFirst.href="javascript:doGetPageData('first')";
                   vhaBefore.disabled=false;
                   vhaBefore.href="javascript:doGetPageData('before')";
                   vhaNext.disabled=false;
                   vhaNext.href="javascript:doGetPageData('next')";
                   vhaLast.disabled=false;
                   vhaLast.href="javascript:doGetPageData('last')";
                }
            }
            else
            {
                vhaFirst.disabled=true;
                vhaFirst.removeAttribute("href");
                
                vhaBefore.disabled=true;
                vhaBefore.removeAttribute("href");
                
                vhaNext.disabled=true;
                vhaNext.removeAttribute("href");
                
                vhaLast.disabled=true;
                vhaLast.removeAttribute("href");
                
            }
        } 
        
         function doClose()
         {
            window.close();
         }
         
         /* 回复 */
         function doReply(vReceiverId)
         {
            var vPageParam = "RecevierId="+vReceiverId+"&PageSource=6";
            var encodeParam = base64encode(vPageParam);
            document.location = "msg_receive_back.aspx?" + encodeParam;
         }
         
         /* 转发 */
         function doForward(vMsgId)
         {
            var vPageParam = "MsgId="+vMsgId+"&PageSource=6";
            var encodeParam = base64encode(vPageParam);
            document.location = "msg_send_edit.aspx?" + encodeParam;
         }
    </script>
</body>
</html>
